package com.betterjr.modules.risk.loanmanage.entity;

import java.math.BigDecimal;
import java.sql.Timestamp;

import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

import com.betterjr.common.annotation.MetaData;
import com.betterjr.common.entity.BetterjrEntity;

@Access(AccessType.FIELD)
@Entity
@Table(name = "t_payment_data")
public class PaymentData implements BetterjrEntity {
    public static final String selectKey = "PaymentData.id";
    /**
     * ID
     */
    @Id
    @Column(name = "ID", columnDefinition = "INTEGER")
    @MetaData(value = "ID", comments = "ID")
    private Long id;

    /**
     * 合同ID
     */
    @Column(name = "P_CONTRACT_ID", columnDefinition = "INTEGER")
    @MetaData(value = "合同ID", comments = "合同ID")
    private Long contractId;

    /**
     * 放款数据ID
     */
    @Column(name = "P_LOAN_DATA_ID", columnDefinition = "INTEGER")
    @MetaData(value = "放款数据ID", comments = "放款数据ID")
    private Long loanDataId;

    /**
     * 扣款计划ID
     */
    @Column(name = "P_PAYMENTL_PLAN_ID", columnDefinition = "INTEGER")
    @MetaData(value = "扣款计划ID", comments = "扣款计划ID")
    private Long paymentPlanId;

    /**
     * 扣款类型，还息：0，还本：1
     */
    @Column(name = "C_PAYMENT_TYPE", columnDefinition = "CHAR")
    @MetaData(value = "扣款类型", comments = "扣款类型，还息：0，还本：1")
    private String paymentType;

    /**
     * 扣款金额
     */
    @Column(name = "N_AMOUNT", columnDefinition = "DECIMAL")
    @MetaData(value = "扣款金额", comments = "扣款金额")
    private BigDecimal amount;

    /**
     * 实际扣款金额
     */
    @Column(name = "N_REAL_AMOUNT", columnDefinition = "DECIMAL")
    @MetaData(value = "实际扣款金额", comments = "实际扣款金额")
    private BigDecimal realAmount;

    /**
     * 应扣款日期
     */
    @Column(name = "D_PAYMENT_DATE", columnDefinition = "DATETIME")
    @MetaData(value = "应扣款日期", comments = "应扣款日期")
    private Timestamp paymentDate;

    /**
     * 实际扣款日
     */
    @Column(name = "D_REAL_PAYMENT_DATE", columnDefinition = "DATETIME")
    @MetaData(value = "实际扣款日", comments = "实际扣款日")
    private Timestamp realPaymentDate;

    /**
     * 创建时间
     */
    @Column(name = "D_CREATE_DATE", columnDefinition = "DATETIME")
    @MetaData(value = "创建时间", comments = "创建时间")
    private Timestamp createDate;

    /**
     * 创建人
     */
    @Column(name = "C_CREATOR", columnDefinition = "VARCHAR")
    @MetaData(value = "创建人", comments = "创建人")
    private String creator;

    /**
     * 创建人ID
     */
    @Column(name = "N_CREATOR_ID", columnDefinition = "INTEGER")
    @MetaData(value = "创建人ID", comments = "创建人ID")
    private Long creatorId;

    private static final long serialVersionUID = 304419459116441987L;

    public Long getId() {
        return id;
    }

    public void setId(final Long id) {
        this.id = id;
    }

    public Long getContractId() {
        return contractId;
    }

    public void setContractId(final Long contractId) {
        this.contractId = contractId;
    }

    public Long getLoanDataId() {
        return loanDataId;
    }

    public void setLoanDataId(final Long loanDataId) {
        this.loanDataId = loanDataId;
    }

    public Long getPaymentPlanId() {
        return paymentPlanId;
    }

    public void setPaymentPlanId(final Long paymentPlanId) {
        this.paymentPlanId = paymentPlanId;
    }

    public String getPaymentType() {
        return paymentType;
    }

    public void setPaymentType(final String paymentType) {
        this.paymentType = paymentType;
    }

    public BigDecimal getAmount() {
        return amount;
    }

    public void setAmount(final BigDecimal amount) {
        this.amount = amount;
    }

    public BigDecimal getRealAmount() {
        return realAmount;
    }

    public void setRealAmount(final BigDecimal realAmount) {
        this.realAmount = realAmount;
    }

    public Timestamp getPaymentDate() {
        return paymentDate;
    }

    public void setPaymentDate(final Timestamp paymentDate) {
        this.paymentDate = paymentDate;
    }

    public Timestamp getRealPaymentDate() {
        return realPaymentDate;
    }

    public void setRealPaymentDate(final Timestamp realPaymentDate) {
        this.realPaymentDate = realPaymentDate;
    }

    public Timestamp getCreateDate() {
        return createDate;
    }

    public void setCreateDate(final Timestamp createDate) {
        this.createDate = createDate;
    }

    public String getCreator() {
        return creator;
    }

    public void setCreator(final String creator) {
        this.creator = creator;
    }

    public Long getCreatorId() {
        return creatorId;
    }

    public void setCreatorId(final Long creatorId) {
        this.creatorId = creatorId;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", contractId=").append(contractId);
        sb.append(", loanDataId=").append(loanDataId);
        sb.append(", paymentPlanId=").append(paymentPlanId);
        sb.append(", paymentType=").append(paymentType);
        sb.append(", amount=").append(amount);
        sb.append(", realAmount=").append(realAmount);
        sb.append(", paymentDate=").append(paymentDate);
        sb.append(", realPaymentDate=").append(realPaymentDate);
        sb.append(", createDate=").append(createDate);
        sb.append(", creator=").append(creator);
        sb.append(", creatorId=").append(creatorId);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }

    @Override
    public boolean equals(final Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        final PaymentData other = (PaymentData) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
                && (this.getContractId() == null ? other.getContractId() == null
                        : this.getContractId().equals(other.getContractId()))
                && (this.getLoanDataId() == null ? other.getLoanDataId() == null
                        : this.getLoanDataId().equals(other.getLoanDataId()))
                && (this.getPaymentPlanId() == null ? other.getPaymentPlanId() == null
                        : this.getPaymentPlanId().equals(other.getPaymentPlanId()))
                && (this.getPaymentType() == null ? other.getPaymentType() == null
                        : this.getPaymentType().equals(other.getPaymentType()))
                && (this.getAmount() == null ? other.getAmount() == null : this.getAmount().equals(other.getAmount()))
                && (this.getRealAmount() == null ? other.getRealAmount() == null
                        : this.getRealAmount().equals(other.getRealAmount()))
                && (this.getPaymentDate() == null ? other.getPaymentDate() == null
                        : this.getPaymentDate().equals(other.getPaymentDate()))
                && (this.getRealPaymentDate() == null ? other.getRealPaymentDate() == null
                        : this.getRealPaymentDate().equals(other.getRealPaymentDate()))
                && (this.getCreateDate() == null ? other.getCreateDate() == null
                        : this.getCreateDate().equals(other.getCreateDate()))
                && (this.getCreator() == null ? other.getCreator() == null
                        : this.getCreator().equals(other.getCreator()))
                && (this.getCreatorId() == null ? other.getCreatorId() == null
                        : this.getCreatorId().equals(other.getCreatorId()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getContractId() == null) ? 0 : getContractId().hashCode());
        result = prime * result + ((getLoanDataId() == null) ? 0 : getLoanDataId().hashCode());
        result = prime * result + ((getPaymentPlanId() == null) ? 0 : getPaymentPlanId().hashCode());
        result = prime * result + ((getPaymentType() == null) ? 0 : getPaymentType().hashCode());
        result = prime * result + ((getAmount() == null) ? 0 : getAmount().hashCode());
        result = prime * result + ((getRealAmount() == null) ? 0 : getRealAmount().hashCode());
        result = prime * result + ((getPaymentDate() == null) ? 0 : getPaymentDate().hashCode());
        result = prime * result + ((getRealPaymentDate() == null) ? 0 : getRealPaymentDate().hashCode());
        result = prime * result + ((getCreateDate() == null) ? 0 : getCreateDate().hashCode());
        result = prime * result + ((getCreator() == null) ? 0 : getCreator().hashCode());
        result = prime * result + ((getCreatorId() == null) ? 0 : getCreatorId().hashCode());
        return result;
    }
}